package com.jk.controller;

import com.jk.dto.TemPosition;
import com.jk.pojo.PagedResponse;
import com.jk.pojo.ResponseResult;
import com.jk.service.TemPositionServiceFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @author yzf
 * @version 1.0
 * @ClassName TemPositionController
 * @program: office
 * @description: TODO
 * @date 2025/2/13 11:01
 */
@Api(tags = "职位管理模块")
@Slf4j
@RestController
@RequestMapping("/tem")
public class TemPositionController {

    @Autowired
    private TemPositionServiceFeign temPositionServiceFeign;

    /**
     * @description: 分页查询
            * @param: [temPosition, pageNum, pageSize]
            * @return: com.jk.pojo.ResponseResult<com.jk.pojo.PagedResponse<com.jk.dto.TemPosition>>
            * @author yzf
            * @date: 2025/2/13 13:17
     */
    @ApiOperation(value = "分页查询",httpMethod = "POST",notes = "")
    @PostMapping("/findTemList")

    private ResponseResult<PagedResponse<TemPosition>> findTemList(@RequestBody @Validated TemPosition temPosition, @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize",defaultValue = "2") Integer pageSize){
        log.info("查询数据"+ temPosition);
        System.out.println("查询数据"+ temPosition);
        return new ResponseResult<>(200,"查询成功",temPositionServiceFeign.findTemList(temPosition,pageNum,pageSize));
    }

    /** 
     * @description: 修改状态
            * @param: [id]
            * @return: com.jk.pojo.ResponseResult
            * @author yzf
            * @date: 2025/2/13 16:20
     */ 
    @ApiOperation(value = "修改状态",httpMethod = "POST",notes = "")
    @PostMapping("/updateStatus")
    private ResponseResult updateStatus(@RequestParam Integer id){
        try {
            temPositionServiceFeign.updateStatus(id);
            return new ResponseResult(200,"修改成功");

        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"修改失败");

        }

    }
    /** 
     * @description: 修改状态
            * @param: [temPosition]
            * @return: com.jk.pojo.ResponseResult
            * @author yzf
            * @date: 2025/2/13 16:20
     */ 
    @ApiOperation(value = "修改状态",httpMethod = "POST",notes = "")
    @PostMapping("/updateState")
    private ResponseResult updateState(@RequestBody TemPosition temPosition){
        try {
            temPositionServiceFeign.updateState(temPosition);
            return new ResponseResult(200,"修改成功");

        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"修改失败");

        }
    }
    @ApiOperation(value = "新增",httpMethod = "POST",notes = "")
    @PostMapping("/addTem")
    private ResponseResult addTem(@RequestBody @Validated TemPosition temPosition){
        try {
            temPositionServiceFeign.addTem(temPosition);
            return new ResponseResult(200,"新增成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"新增失败");

        }
    }
    @ApiOperation(value = "删除",httpMethod = "POST",notes = "")
    @PostMapping("/delTemById")
    private ResponseResult delTemById(@RequestParam Integer id){
        try {
            temPositionServiceFeign.delTemById(id);
            return new ResponseResult(200,"删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"删除失败");

        }
    }

    @ApiOperation(value = "修改",httpMethod = "POST",notes = "")
    @PostMapping("/updateTem")
    private ResponseResult updateTem(@RequestBody TemPosition temPosition){
        try {
            temPositionServiceFeign.updateTem(temPosition);
            return new ResponseResult(200,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult(500,"修改失败");

        }
    }
    @ApiOperation(value = "回显",httpMethod = "GET",notes = "")
    @GetMapping("/getTem")
    private ResponseResult<TemPosition> getTem(@RequestParam Integer id){
        return new ResponseResult(200,"回显成功",temPositionServiceFeign.getTem(id));
    }

    @ApiOperation(value = "查询职位",httpMethod = "POST",notes = "")
    @PostMapping("/findTemPosition")
    private ResponseResult<List<TemPosition>> findTemPosition(@RequestBody TemPosition temPosition){
        return new ResponseResult(200,"查询成功",temPositionServiceFeign.findTemPosition(temPosition));
    }

    



}
